package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.service.MenuService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author : [chenxys]
 * @version : [v1.0]
 * @Description : 菜单管理
 * @createTime : [2022/6/2 17:28]
 */
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Reference
    private MenuService menuService;


    /**
     * 根据用户角色ID查询对应的菜单
     * @author chenxys
     * @param roleId 角色ID
     * @return com.itheima.entity.Result
     */
    @RequestMapping(value = "/getMenuByUserRoleId")
    public Result getMenuByUserRoleId(Integer roleId){
        try {
            List<Map> menuList = menuService.getMenuByUserRoleId(roleId);
            return new Result(true,MessageConstant.GET_MENU_SUCCESS,menuList);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_MENU_FAIL);
        }
    }
}
